<script setup lang="ts">
import {computed} from "vue";
import {useUserStore} from "@/stores";

const userStore = useUserStore();
const isLogin = computed(()=>userStore.userToken);

const onLogout = ()=>{
  uni.showModal({
    title: '提示',
    content: '确定退出登录？',
    success: (res) => {
      if (res.confirm) {
        userStore.clearUserInfo();
        uni.switchTab({
          url: '/pages/mine/index'
        })
      }
    }
  })
}
</script>

<template>
  <view>
    <up-cell-group>
      <up-cell
          title="用户协议"
          isLink
          url="/pages/public/richtext?slug=user_protocol"
      ></up-cell>
      <up-cell
          title="隐私协议"
          isLink
          url="/pages/public/richtext?slug=privacy_protocol"
      ></up-cell>
    </up-cell-group>

  </view>
  <view style="padding: 20px;">
    <up-button @tap="onLogout" v-if="isLogin" color="#f0ad4e" shape="circle" text="退出登录" ></up-button>
  </view>
</template>

<style scoped lang="scss">

</style>